Lesson 11 - String manipulation

Strings are a collection of characters. A character is a single letter, number or symbol. This includes space. Characters use ascii codes in comparison which leads to the odd situation of "Z" < "a". Make sure you read the related links.

To access a single character in a string you can specify it's index. The first letter would be index 0, the second index 1 and so on. The code below demonstrates character access.


s = "hello"
print s[1] # print e
print s[4] # print o

Python does not have the normal left(), right(), mid() methods. You should read up on the syntax to find out how to do this.